|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ServiceReferanceParser.java | 75% | 80% | 80% | 78.9% |
|
1 |
/*
|
|
2 |
* Copyright 2001-2004 The Apache Software Foundation.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
|
|
17 |
package org.apache.geronimo.ews.ws4j2ee.parsers;
|
|
18 |
|
|
19 |
import org.apache.geronimo.ews.ws4j2ee.context.webservices.client.ServiceReferanceImpl;
|
|
20 |
import org.apache.geronimo.ews.ws4j2ee.context.webservices.client.interfaces.ServiceReferanceContext;
|
|
21 |
import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
|
|
22 |
import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
|
|
23 |
import org.w3c.dom.Document;
|
|
24 |
import org.w3c.dom.Element;
|
|
25 |
import org.w3c.dom.Node;
|
|
26 |
import org.w3c.dom.NodeList;
|
|
27 |
|
|
28 |
import java.io.InputStream;
|
|
29 |
|
|
30 |
/**
|
|
31 |
* <service-ref>
|
|
32 |
* <service-ref-name>service/Joe</service-ref-name>
|
|
33 |
* <service-interface>javax.xml.rpc.Service</service-interface>
|
|
34 |
* <wsdl-file>WEB-INF/joe.wsdl</wsdl-file>
|
|
35 |
* <jaxrpc-mapping-file>WEB-INF/joe.xml</jaxrpc-mapping-file>
|
|
36 |
* <service-qname></service-qname>
|
|
37 |
* <port-component-ref>
|
|
38 |
* <service-endpoint-interface>sample.Joe</service-endpoint-interface>
|
|
39 |
* <port-component-link>JoePort</port-component-link>
|
|
40 |
* </port-component-ref>
|
|
41 |
* <handler>
|
|
42 |
* <handler-name></handler-name>
|
|
43 |
* <handler-class></handler-class>
|
|
44 |
* </handler>
|
|
45 |
* </service-ref>
|
|
46 |
*
|
|
47 |
* @author Srinath Perera(hemapani@opensource.lk)
|
|
48 |
*/
|
|
49 |
public class ServiceReferanceParser { |
|
50 |
private ServiceReferanceContext ref;
|
|
51 |
|
|
52 | 6 |
public ServiceReferanceParser(InputStream inputStream) throws GenerationFault { |
53 | 6 |
try {
|
54 | 6 |
Document doc = Utils.createDocument(inputStream); |
55 | 6 |
Element root = doc.getDocumentElement(); |
56 | 6 |
Element serviceref = findServiceReferance(root); |
57 | 6 |
if (serviceref != null) |
58 | 6 |
parse(serviceref); |
59 |
else
|
|
60 | 0 |
throw new GenerationFault("No service Referance in the file"); |
61 |
} catch (Exception e) {
|
|
62 | 0 |
e.printStackTrace(); |
63 | 0 |
throw GenerationFault.createGenerationFault(e);
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
/**
|
|
68 |
* find the service-ref element from the xml file.
|
|
69 |
*
|
|
70 |
* @param ele
|
|
71 |
* @return
|
|
72 |
*/
|
|
73 | 7 |
public Element findServiceReferance(Element ele) {
|
74 | 7 |
if ("service-ref".equals((ele).getLocalName())) { |
75 | 6 |
return ele;
|
76 |
} else {
|
|
77 | 1 |
NodeList nodes = ele.getChildNodes(); |
78 | 2 |
for (int i = 0; i < nodes.getLength(); i++) { |
79 | 2 |
Node node = nodes.item(i); |
80 | 2 |
if (node instanceof Element) { |
81 | 1 |
return findServiceReferance((Element) node);
|
82 |
} |
|
83 |
} |
|
84 | 0 |
return null; |
85 |
} |
|
86 |
} |
|
87 |
|
|
88 | 0 |
public ServiceReferanceParser(Element refEle) {
|
89 | 0 |
parse(refEle); |
90 |
} |
|
91 |
|
|
92 | 6 |
public void parse(Element refEle) { |
93 | 6 |
ref = new ServiceReferanceImpl();
|
94 | 6 |
Element root = refEle; |
95 | 6 |
ref.setServicerefName(Utils.getElementValue(root.getElementsByTagName("service-ref-name")));
|
96 | 6 |
ref.setServiceInterface(Utils.getElementValue(root.getElementsByTagName("service-interface")));
|
97 | 6 |
ref.setWsdlFile(Utils.getElementValue(root.getElementsByTagName("wsdl-file")));
|
98 | 6 |
ref.setJaxrpcmappingFile(Utils.getElementValue(root.getElementsByTagName("jaxrpc-mapping-file")));
|
99 |
} |
|
100 |
|
|
101 |
/**
|
|
102 |
* @return
|
|
103 |
*/
|
|
104 | 6 |
public ServiceReferanceContext getRef() {
|
105 | 6 |
return ref;
|
106 |
} |
|
107 |
|
|
108 |
} |
|
109 |
|
|